/*
 * @(#)EmploymentTransformer.java
 * Date 2013-08-17
 * Version 1.0
 * Author Jim Horner
 * Copyright (c)2012
 */


package us.hornerscorners.lamppost.pix.transformer;

import javax.enterprise.context.ApplicationScoped;

import javax.inject.Inject;

import org.hl7.v3.PRPAMT201301UV02Employee;

import us.hornerscorners.lamppost.exception.ServiceActionException;

import us.hornerscorners.lamppost.hl7v3common.utils.HL7Utils;

import us.hornerscorners.lamppost.model.patient.Employment;

import us.hornerscorners.lamppost.transformer.AbstractTransformer;


/**
 *
 * @author jim
 */
@ApplicationScoped
public class EmploymentTransformer
        extends AbstractTransformer<PRPAMT201301UV02Employee, Employment> {

    /** Field description */
    @Inject
    private CodedElementTransformer codedElementTransformer;

    /** Field description */
    @Inject
    private ContactOrganizationTransformer contactOrganizationTransformer;

    /**
     * Method description
     *
     *
     * @param prpaEmployee
     *
     * @return
     */
    @Override
    public Employment transform(PRPAMT201301UV02Employee prpaEmployee)
            throws ServiceActionException {

        Employment result = null;

        if (prpaEmployee != null) {

            result = new Employment();

            result.setEffectiveTime(
                HL7Utils.toEffectiveTime(prpaEmployee.getEffectiveTime()));

            result.setOccupationCode(
                this.codedElementTransformer.transform(prpaEmployee.getOccupationCode()));

            result.setOrganization(
                this.contactOrganizationTransformer.transform(
                    prpaEmployee.getEmployerOrganization()));

            result.setStatusCode(
                this.codedElementTransformer.transform(prpaEmployee.getStatusCode()));
        }

        return result;
    }
}
